package com.andy.mvp.test.precenter;

import com.andy.app_core.net.databus.RegisterRxBus;
import com.andy.mvp.test.bean.Girl;
import com.andy.mvp.test.model.IGirlModel;
import com.andy.mvp.test.model.IGirlModelImpl;
import com.andy.mvp.test.view.IGirlView;

import java.lang.ref.WeakReference;
import java.util.ArrayList;

/**
 * @version V1.0
 * @描述: 所有的业务逻辑都在表示层完成
 * @auth: Created by AN .
 * @time: 2020/3/26 00:03
 * @des
 */
public class GirlPresenter<T extends IGirlView> {
    //1.View层的引用
    WeakReference<T> mView;///弱引用,系统内存不足的时候,会把引用打断

    public GirlPresenter(T mView) {
        this.mView = new WeakReference<T>(mView);
        iGirlModel.loadGril();
    }
    //2.Model层的引用
    IGirlModel iGirlModel=new IGirlModelImpl();

//    //3.执行UI逻辑操作
//    public void fetch(){
//        if(mView.get() != null && iGirlModel != null){
//            iGirlModel.loadGirl(new IGirlModel.GirlOnLoadListener() {
//                @Override
//                public void onComplete(List<Girl> girls) {
//                    mView.get().showGirls(girls);
//                }
//            });
//        }
//    }

    @RegisterRxBus
    public void  getShowGirlData(ArrayList<Girl> list){
        mView.get().showGirls(list);
    }
}
